home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / vgamaze4.zip / CELL.CPP next >
C/C++ Source or Header  |  1994-02-14  |  2KB  |  80 lines

  1. #include "cell.h"
  2.  
  3. void cell::knock_down_wall(char wall_num)
  4. //      Changes the bit for the appropriate wall to zero.
  5. //      For square rooms,
  6. //           0 represents the north wall,
  7. //           1 represents the west wall,
  8. //           2 represents the south wall, and
  9. //           3 represents the east wall.
  10. //      For hexagonal rooms,
  11. //           0 represents the north wall,
  12. //           1 represents the northwest wall,
  13. //           2 represents the southwest wall, 
  14. //           3 represents the south wall.
  15. //           4 represents the southeast wall, and
  16. //           5 represents the northeast wall.
  17.   {
  18.     switch (wall_num)
  19.       {
  20.         case '\0':
  21.           wall_present&=62;
  22.           break;
  23.         case '\1':
  24.           wall_present&=61;
  25.           break;
  26.         case '\2':
  27.           wall_present&=59;
  28.           break;
  29.         case '\3':
  30.           wall_present&=55;
  31.           break;
  32.         case '\4':
  33.           wall_present&=47;
  34.           break;
  35.         default:
  36.           wall_present&=31;
  37.           break;
  38.       }
  39.   }
  40.  
  41. int cell::wall_up(char wall_num)
  42. //     Returns whether or not a wall is present.
  43. //      For square rooms,
  44. //           0 represents the north wall,
  45. //           1 represents the west wall,
  46. //           2 represents the south wall, and
  47. //           3 represents the east wall.
  48. //      For hexagonal rooms,
  49. //           0 represents the north wall,
  50. //           1 represents the northwest wall,
  51. //           2 represents the southwest wall, 
  52. //           3 represents the south wall.
  53. //           4 represents the southeast wall, and
  54. //           5 represents the northeast wall.
  55.   {
  56.     int result=int(wall_present);
  57.     switch (wall_num)
  58.       {
  59.         case '\0':
  60.           result&=1;
  61.           break;
  62.         case '\1':
  63.           result&=2;
  64.           break;
  65.         case '\2':
  66.           result&=4;
  67.           break;
  68.         case '\3':
  69.           result&=8;
  70.           break;
  71.         case '\4':
  72.           result&=16;
  73.           break;
  74.         default:
  75.           result&=32;
  76.           break;
  77.       }
  78.     return result;
  79.   }
  80.